// pages/netCase/party/party.js
import { partyData, party, nature, legal, other } from '../../../js/netCase/party/partyData.js'
import ecfsConfig from '../../../config/ecfs.config.js'
import { merge } from '../../../utils/util.js'
import locale from '../../../config/locale/zh-CN/netCase/party.js'
import * as partyBussiness from '../../../js/netCase/party/partyBussiness.js'
import * as partyApi from '../../../api/party.js'
/**picker***/
var model = require('../../../component/area/model.js')
var show = false;
var item = {};
/**picker***/

Page({
  /**
   * 页面的初始数据
   */
  data: {
    partyData,
    locale,
    party,
    nature,
    legal,
    other,
    caseId: '',
    partyId: '',
    agentIds: [],
    CertifIndex: 0,
    partyType: 1,//当事人类型number
    partyTypeName: '自然人',//
    caseType: 2,
    caseTypeName: '民事',
    litigationStatus: 1,
    litigationStatusName: '原告',
    JobIndex: -1,
    unitNatureIndex: -1,
    LegalJobIndex: -1,
    otherJobIndex: -1,
    formIsFrom: 1,//点击新建当事人，1-原告，2-被告，3-第三人，4-代理人,通过上一界面传值0是来自于列表
    content: {},
    certificates: [],//保存上传证件
    partyTypeIndex: 0,
    item: {
      show: show
    },
    isDisabled: false,//是否可编辑 true -不可编辑  false- 可编辑
    currentType: 1 //1 户籍地 2，居住地,3,法人单位地址  4 其他组织组织地址
  },
  /**
   * 删除证件照
   */
  deleteImgFront: function (e) {
    var that = this, front = -1

    if (that.data.partyType === 1) {
      for (let index in that.data.nature.certificates) {
        if (that.data.nature.certificates[index].front === 1) {
          front = index
        }
      }
      that.setData({
        'partyData.isShowFront': true,
        'partyData.frontImgUrl': '',
      })
      if (front != -1) {
        this.setData({
          'nature.certificates[front]': {}
        })
      }

    } else if (that.data.partyType === 2) {
      that.setData({
        'partyData.isShowLegalCer': true,
        'partyData.legalCerImgUrl': '',
        'legal.certificates': []
      })
    } else if (that.data.partyType === 3) {
      that.setData({
        'partyData.isShowOtherCer': true,
        'partyData.otherCerImgUrl': '',
        'other.certificates': []
      })
    }
  },
  /**
   * 删除背面证件照
   */
  deleteImgBack: function (e) {
    let front = -1
    for (let index in this.data.nature.certificates) {
      if (this.data.nature.certificates[index].front === 2) {
        front = index
      }
    }
    this.setData({
      'partyData.isShowBack': true,
      'partyData.backImgUrl': '',

    })
    if (front != -1) {
      this.setData({
        'nature.certificates[front]': {}
      })
    }
  },
  /**
   * 上传证件照正面
   */
  uploadFront: function (e) {
    var that = this
    wx.chooseImage({
      count: 1, // 默认9
      sizeType: ['compressed'], // 可以指定是原图还是压缩图，默认二者都有
      sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
      success: function (res) {
        // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
        var tempFilePaths = res.tempFilePaths[0]
        if (that.data.partyType === 1) {
          that.setData({
            'partyData.isShowFront': false,
            'partyData.frontImgUrl': tempFilePaths
          })
        } else if (that.data.partyType === 2) {
          that.setData({
            'partyData.isShowLegalCer': false,
            'partyData.legalCerImgUrl': tempFilePaths
          })
        } else if (that.data.partyType === 3) {
          that.setData({
            'partyData.isShowOtherCer': false,
            'partyData.otherCerImgUrl': tempFilePaths
          })
        }
        wx.uploadFile({
          url: ecfsConfig.IS_PRODUCTION ? (ecfsConfig.SERVER_DOMAIN + ecfsConfig.UPLOAD_FILE_URL) : (ecfsConfig.SERVER_DOMAIN + ecfsConfig.RAP_URL_PREFIX + ecfsConfig.UPLOAD_FILE_URL), //仅为示例，非真实的接口地址
          header: {
            'Auth-Token': wx.getStorageSync('accessToken')
          },
          filePath: tempFilePaths,
          name: 'file',
          success: function (res) {
            let data = JSON.parse(res.data), backFile = {}, files, flag = -1
            if (that.data.partyType === 1) {
              files = merge([], that.data.nature.certificates)
            } else if (that.data.partyType === 2) {
              files = merge([], that.data.legal.certificates)
            } else if (that.data.partyType === 3) {
              files = merge([], that.data.other.certificates)
            }
            if (data.code === 200) {
              backFile.caseId = that.data.caseId
              backFile.fileExtension = data.body[0].extension
              backFile.fileSize = data.body[0].fileSize
              backFile.front = 1//反面
              backFile.id = data.body[0].uuid
              backFile.newName = data.body[0].fileName
              backFile.oldName = data.body[0].originalFileName
              backFile.ownerId = that.data.partyId
              for (let index in files) {
                if (files[index].front === 1) {
                  files[index] = backFile
                  flag = index
                }
              }
              if (flag === -1) {
                files.push(backFile)
              }
              if (that.data.partyType === 1) {
                that.setData({
                  'nature.certificates': files
                })
              } else if (that.data.partyType === 2) {
                that.setData({
                  'legal.certificates': files
                })
              } else if (that.data.partyType === 3) {
                that.setData({
                  'other.certificates': files
                })
              }
              console.log(that.data.other)
            } else {
              console.log(data.code)
            }
          }
        })
      }
    })
  },
  /**
   * 上传证件照背面
   */
  uploadBack: function (e) {
    let that = this
    wx.chooseImage({
      count: 1, // 默认9
      sizeType: ['compressed'], // 可以指定是原图还是压缩图，默认二者都有
      sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
      success: function (res) {
        // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
        var tempFilePaths = res.tempFilePaths[0]
        that.setData({
          'partyData.isShowBack': false,
          'partyData.backImgUrl': tempFilePaths
        })
        wx.uploadFile({
          url: ecfsConfig.IS_PRODUCTION ? (ecfsConfig.SERVER_DOMAIN + ecfsConfig.UPLOAD_FILE_URL) : (ecfsConfig.SERVER_DOMAIN + ecfsConfig.RAP_URL_PREFIX + ecfsConfig.UPLOAD_FILE_URL), //仅为示例，非真实的接口地址
          header: {
            'Auth-Token': wx.getStorageSync('accessToken')
          },
          filePath: tempFilePaths,
          name: 'file',
          success: function (res) {
            let data = JSON.parse(res.data), backFile = {}, flag = -1, files = merge([], that.data.nature.certificates)
            if (data.code === 200) {
              backFile.caseId = that.data.caseId
              backFile.fileExtension = data.body[0].extension
              backFile.fileSize = data.body[0].fileSize
              backFile.front = 2//反面
              backFile.id = data.body[0].uuid
              backFile.newName = data.body[0].fileName
              backFile.oldName = data.body[0].originalFileName
              backFile.ownerId = that.data.partyId
              for (let index in files) {
                if (files[index].front === 2) {
                  files[index] = backFile
                  flag = index
                }
              }
              if (flag === -1) {
                files.push(backFile)
              }
              that.setData({
                'nature.certificates': files
              })
            } else {
              console.log(data.code)
            }
          }
        })
      }
    })
  },
  /**
 * 预览证件照
 */
  previewCer: function (e) {
    var that = this, url
    if (that.data.partyType === 1) {
      url = [that.data.partyData.frontImgUrl]
    } else if (that.data.partyType === 2) {
      url = [that.data.partyData.legalCerImgUrl]
    } else if (that.data.partyType === 3) {
      url = [that.data.partyData.otherCerImgUrl]
    }
    wx.previewImage({
      urls: url // 需要预览的图片http链接列表
    })
  },
  /**
   * 预览证件照背面
   */
  previewCerBack: function (e) {
    var that = this
    wx.previewImage({
      urls: [that.data.partyData.backImgUrl] // 需要预览的图片http链接列表
    })
  },
  /**picker***/
  /**
 * 输入框获取焦点，隐藏pickview
 */
  onFacus: function (e) {
    this.hiddenFloatView();
  },

  //生命周期函数--监听页面初次渲染完成
  onReady: function (e) {
    //  var that = this;
    //请求数据
    //  model.updateAreaData(that, 0, e);
  },
  /**
   * 选择户籍地
   */
  selectHuJi: function (e) {
    if (!this.data.isDisabled) {
      this.setData({
        currentType: 1
      });
      this.pickup();
    }
  },
  /**
   * 选择常住地
   */
  selectJuZhu: function (e) {
    if (!this.data.isDisabled) {
      this.setData({
        currentType: 2
      });
      this.pickup();
    }

  },
  /**
   * 法人单位地址
   */
  selectUnit: function (e) {
    if (!this.data.isDisabled) {
      this.setData({
        currentType: 3
      });
      this.pickup();
    }
  },
  /**
   * 其他组织地址
   */
  selectOrgan: function (e) {
    if (!this.data.isDisabled) {
      this.setData({
        currentType: 4
      });
      this.pickup();
    }
  },
  pickup: function (e) {
    var that = this;
    model.pickup(this, "", "", "", function (result) {
      that.setData({
        item: result
      });
    })
  },
  //取消或者 隐藏picker-view
  hiddenFloatView: function (e) {
    var that = this;
    model.pickDown(this, function (result) {
      that.setData({
        item: result
      });
    })
  },
  //选取了值，再隐藏view
  okFloatView: function (e) {
    var that = this;
    model.pickDown(this, function (result) {
      that.setData({
        item: result
      });
      var value = result.value;
      var sheng = result.provinces[value[0]];
      var shi = result.citys[value[1]];
      var xian = result.countys[value[2]];
      if (that.data.currentType === 2) {//常住地
        that.setData({
          'nature.address': sheng.label + shi.label + xian.label,
          'nature.addressCode': sheng.value + '-' + shi.value + '-' + xian.value
        });
      } else if (that.data.currentType === 1) {//户籍地
        that.setData({
          'nature.homeRegister': sheng.label + shi.label + xian.label,
          'nature.homeRegisterCode': sheng.value + '-' + shi.value + '-' + xian.value
        });
      } else if (that.data.currentType === 3) {//法人单位地址
        that.setData({
          'legal.unitAddress': sheng.label + shi.label + xian.label,
          'legal.unitAddressCode': sheng.value + '-' + shi.value + '-' + xian.value
        });
      } else if (that.data.currentType === 4) {//其他组织组织地址
        that.setData({
          'other.unitAddress': sheng.label + shi.label + xian.label,
          'other.unitAddressCode': sheng.value + '-' + shi.value + '-' + xian.value
        });
      }
    })
  },
  //滑动事件
  bindChange: function (e) {
    var that = this;
    model.pickScroll(e, this, function (result) {
      that.setData({
        item: result
      });
    });
  },
  /**
   *其他组织职业
   */
  bindOtherJob: function (e) {
    this.setData({
      otherJobIndex: e.detail.value
    })
    for (var index in this.data.partyData.jobData) {
      if (e.detail.value == index) {
        this.setData({
          'other.jobName': this.data.partyData.jobData[index].name,
          'other.job': Number(this.data.partyData.jobData[index].id)
        })
      }
    }
  },
  /**
   * 负责人姓名
   */
  bindOtherName: function (e) {
    this.setData({
      'other.name': e.detail.value
    })
  },
  /**
   * 其他组织组织机构代码
   */
  bindOtherOrganizationCode: function (e) {
    this.setData({
      'other.organizationCode': e.detail.value
    })
  },
  /**
 * 组织详细地址
 */
  bindOtherUnitAddressDetail: function (e) {
    this.setData({
      'other.unitAddressDetail': e.detail.value
    })
  },
  /**
   * 组织名称
   */
  bindOtherUnitName: function (e) {
    this.setData({
      'other.unitName': e.detail.value
    })
  },
  /**
   * 其他组织电话号码
   */
  bindOtherPhoneNum: function (e) {
    this.setData({
      'other.phoneNumber': e.detail.value
    })
  },
  /**
   * 法人职务
   */
  bindLegalJob: function (e) {
    this.setData({
      LegalJobIndex: e.detail.value
    })
    for (var index in this.data.partyData.jobData) {
      if (e.detail.value == index) {
        this.setData({
          'legal.jobName': this.data.partyData.jobData[index].name,
          'legal.job': Number(this.data.partyData.jobData[index].id)
        })
      }
    }
  },
  /**
   * 法定代表人姓名
   */
  bindLegalName: function (e) {
    this.setData({
      'legal.name': e.detail.value
    })
  },
  /**
   * 单位性质
   */
  bindNnitNature: function (e) {
    this.setData({
      unitNatureIndex: e.detail.value
    })
    for (var index in this.data.partyData.unitNatureData) {
      if (e.detail.value == index) {
        this.setData({
          'legal.unitNature': this.data.partyData.unitNatureData[index].name,
          'legal.unitNatureName': Number(this.data.partyData.unitNatureData[index].id)
        })
      }
    }
  },
  /**
   * 法人组织机构代码
   */
  bindOrganizationCode: function (e) {
    this.setData({
      'legal.organizationCode': e.detail.value
    })
  },
  /**
   * 单位详细地址
   */
  bindUnitAddressDetail: function (e) {
    this.setData({
      'legal.unitAddressDetail': e.detail.value
    })
  },
  /**
   * 法人手机号码
   */
  bindLegalPhoneNum: function (e) {
    this.setData({
      'legal.phoneNumber': e.detail.value
    })
  },
  /**
   * 法人单位名称
   */
  bindLeaglUnitName: function (e) {
    this.setData({
      'legal.unitName': e.detail.value
    })
  },
  /**
   * 获取单位名称
   */
  bindUnitName: function (e) {
    this.setData({
      'legal.unitName': e.detail.value
    })
  },
  bindHomeRegisterDetail: function (e) {
    this.setData({
      'nature.homeRegisterDetail': e.detail.value
    })
  },
  /**
   * 常住地详细地址
   */
  bindAddressDetail: function (e) {
    this.setData({
      'nature.addressDetail': e.detail.value
    })
  },
  /**
   * 获取证件号码
   */
  bindCertifyNum: function (e) {
    this.setData({
      'nature.certificateNumber': e.detail.value
    })
  },
  /**
   * 获取手机号码
   */
  bindPhoneNum: function (e) {
    this.setData({
      'nature.phoneNumber': e.detail.value
    })
  },

  /**
   * 获取职业
   */
  bindJob: function (e) {
    this.setData({
      JobIndex: e.detail.value
    })
    for (var index in this.data.partyData.jobData) {
      if (e.detail.value == index) {
        this.setData({
          'nature.jobName': this.data.partyData.jobData[index].name,
          'nature.job': Number(this.data.partyData.jobData[index].id)
        })
      }
    }
  },
  /**
   * 改变当事人类型
   */
  changePartyType: function (e) {
    this.setData({
      partyTypeIndex: e.detail.value
    })
    for (var index in this.data.partyData.partyTypeList) {
      if (index === this.data.partyTypeIndex) {
        this.setData({
          partyType: Number(this.data.partyData.partyTypeList[index].id),
          partyTypeName: this.data.partyData.partyTypeList[index].name
        })
      }
    }
  },
  /**
   * 获取证件类型
   */
  bindCertificateType: function (e) {
    this.setData({
      CertifIndex: e.detail.value
    })
    for (var index in this.data.partyData.certificateTypeList) {
      if (e.detail.value == index) {
        this.setData({
          'nature.certificateType': Number(this.data.partyData.certificateTypeList[index].id),
          'nature.certificateTypeName': this.data.partyData.certificateTypeList[index].name
        })
      }
    }
  },
  /**
   * 绑定姓名
   */
  bindName: function (e) {
    this.setData({
      'nature.name': e.detail.value
    })
  },
  /**
   * 获取性别
   */
  genderChange: function (e) {
    this.setData({
      'nature.gender': e.detail.value
    })
  },
  /**
   * 获取出生日期
   */
  bindBrithday: function (e) {
    this.setData({
      'nature.birthday': e.detail.value
    })
  },
  /**
   * 提示
   */
  showTips(msg) {
    wx.showToast({
      title: msg,
      icon: 'none',
      duration: 1000
    })
  },
  /**
   * 保存当事人
   */
  saveParty: function (e) {
    var formIsFrom = this.data.formIsFrom, flag = true,
      partyType = Number(this.data.partyType),
      nature = merge({}, this.data.nature), legal = merge({}, this.data.legal),
      other = merge({}, this.data.other)
    if (partyType === 1) {//自然人
      if (nature.name === '') {
        this.showTips('请输入姓名')
        flag = false
      } else if (nature.gender === '') {
        this.showTips('请选择性别')
        flag = false
      } else if (nature.certificateNumber.length < 18) {
        this.showTips('请输入正确证件号码')
        flag = false
      } else if (nature.phoneNumber.length < 11) {
        this.showTips('请输入正确手机号码')
        flag = false
      } else if ((nature.homeRegisterCode != "" && nature.homeRegisterDetail != "") || (nature.addressCode != "" && nature.addressDetail != "")) {
        if ((nature.homeRegisterCode === "" && nature.homeRegisterDetail != "") || (nature.homeRegisterCode != "" && nature.homeRegisterDetail === "")) {
          this.showTips('请完整填写户籍地址')
          flag = false
        } else if ((nature.addressCode === "" && nature.addressDetail != "") || ((nature.addressCode != "" && nature.addressDetail === ""))) {
          this.showTips('请完整填写常住地址')
          flag = false
        }
      } else {
        this.showTips('户籍地住所地至少填一个')
        flag = false
      }
      if (this.data.litigationStatus === 1) {
        if (nature.certificates.length < 2) {
          this.showTips('请上传完整证件照')
          flag = false
        }
      } else {
        if (nature.certificates.length === 1) {
          this.showTips('请上传完整证件照')
          flag = false
        }
      }
      if (flag) {
        this.setData({
          content: nature
        })
      }
    } else if (partyType === 2) {//法人
      if (legal.unitName === '') {
        this.showTips('请输入单位名称')
        flag = false
      } else if (legal.phoneNumber.length < 11) {
        this.showTips('请输入正确手机号码')
        flag = false
      } else if (legal.unitAddress === '' || legal.unitAddressDetail === '') {
        this.showTips('请完整填写地址')
        flag = false
      } else if (legal.organizationCode === '') {
        this.showTips('请输入组织机构代码')
        flag = false
      } else if (legal.unitNature === '') {
        this.showTips('请选择单位性质')
        flag = false
      } else if (legal.name === '') {
        this.showTips('请输入法人姓名')
        flag = false
      } else if (legal.job === '') {
        this.showTips('请选择法人职务')
        flag = false
      }
      if (this.data.litigationStatus === 1) {
        if (legal.certificates.length != 1) {
          this.showTips('请上传执业证照')
          flag = false
        }
      }
      if (flag) {
        this.setData({
          content: legal
        })
      }
    } else if (partyType === 3) {
      if (other.unitName === '') {
        this.showTips('请输入组织名称')
        flag = false
      } else if (other.phoneNumber.length < 11) {
        this.showTips('请输入正确手机号码')
        flag = false
      } else if (other.unitAddress === '' || other.unitAddressDetail === '') {
        this.showTips('请输入完整地址')
        flag = false
      } else if (other.organizationCode === '') {
        this.showTips('请输入组织机构代码')
        flag = false
      } else if (other.name === '') {
        this.showTips('请输入负责人姓名')
        flag = false
      } else if (other.job === '') {
        this.showTips('请选择职务')
        flag = false
      }
      if (this.data.litigationStatus === 1) {
        if (other.certificates.length != 1) {
          this.showTips('请上传执业证照')
          flag = false
        }
      }
      if (flag) {
        this.setData({
          content: other
        })
      }
    }
    if (formIsFrom != 0) {//来自于新建
      if (formIsFrom === 1) {//新建原告
        this.setData({
          litigationStatus: 1,
          litigationStatusName: '原告'
        })
      } else if (formIsFrom === 2) {
        this.setData({
          litigationStatus: 2,
          litigationStatusName: '被告'
        })
      } else if (formIsFrom === 3) {
        this.setData({
          litigationStatus: 3,
          litigationStatusName: '第三人'
        })
      }


    }
    console.log(flag)
    if (flag) {
      var con = merge({}, this.data.content)
      con.litigationStatus = this.data.litigationStatus
      con.litigationStatusName = this.data.litigationStatusName
      con.partyType = this.data.partyType
      con.partyTypeName = this.data.partyTypeName
      con.caseId = this.data.caseId
      con.caseTypeName = this.data.caseTypeName
      con.caseType = this.data.caseType
      this.setData({
        content: con
      })
      console.log('con')
      console.log(this.data.content)
    }
    // this.data.content = merge(this.data.content, con)
    if (flag) {
      partyBussiness.handleSaveParty(this)
    }
  },
  /**
   * 删除当事人
   */
  deleteParty: function (e) {
    let party, agentIds = []
    if (this.data.partyType === 1) {//自然人
      party = this.data.nature
    } else if (this.data.partyType === 2) {//法人
      party = this.data.legal
    } else if (this.data.partyType === 3) {//其他组织
      party = this.data.other
    }
    if (party.agent.length > 0) {//取代理人id
      for (let index in party.agent) {
        agentIds.push(party.agent[index].id)
      }
    }
    if (party.caseId != '' && party.id != '') {
      let deleteContent = {
        agentIds: agentIds,//考虑获取agentIds???
        caseId: party.caseId,
        id: party.id
      }
      partyBussiness.handleDeleteParty(this, deleteContent)
    } else {
      this.showTips('信息有误，删除失败')
    }
  },
  /**
   * 重置表单
   */
  formReset: function () {
    console.log('form发生了reset事件')
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // 取url传入数据
    this.setData({
      formIsFrom: Number(options.formIsFrom),
      partyId: options.partyId
    })
    //获取当事人信息
    if (this.data.formIsFrom === 0) {
      const config = {
        url: ecfsConfig.IS_PRODUCTION ? (ecfsConfig.SERVER_DOMAIN + ecfsConfig.SELECT_PARTY_URL) : (ecfsConfig.SERVER_DOMAIN + ecfsConfig.RAP_URL_PREFIX + ecfsConfig.SELECT_PARTY_URL),
        data: { id: options.partyId },
      }
      partyApi.selectParty(config).then(res => {
        let data = res.data
        if (data.code === 200) {
          let agentIds = [], party
          for (let index in data.body.agent) {
            agentIds.push(data.body.agent[index].id)
          }
          this.setData({
            agentIds: agentIds
          })
          party = data.body.party
          party.agentIds = agentIds
          if (data.body.party.partyType === 1) {
            this.setData({
              nature: party
            })
            for (let index in this.data.nature.certificates) {
              if (this.data.nature.certificates[index].front === 1) {
                this.setData({
                  'partyData.frontImgUrl': ecfsConfig.IS_PRODUCTION ? (ecfsConfig.SERVER_DOMAIN + ecfsConfig.PROVIEW_FILE_URL + this.data.nature.certificates[index].newName) : (ecfsConfig.SERVER_DOMAIN + ecfsConfig.RAP_URL_PREFIX + ecfsConfig.PROVIEW_FILE_URL + this.data.nature.certificates[index].newName),
                  'partyData.isShowFront': false,
                })
              } else {
                this.setData({
                  'partyData.backImgUrl': ecfsConfig.IS_PRODUCTION ? (ecfsConfig.SERVER_DOMAIN + ecfsConfig.PROVIEW_FILE_URL + this.data.nature.certificates[index].newName) : (ecfsConfig.SERVER_DOMAIN + ecfsConfig.RAP_URL_PREFIX + ecfsConfig.PROVIEW_FILE_URL + this.data.nature.certificates[index].newName),
                  'partyData.isShowBack': false,
                })
              }
            }
            console.log(this.data.partyData)
          } else if (data.body.party.partyType === 2) {
            this.setData({
              legal: party,
              'partyData.legalCerImgUrl': ecfsConfig.IS_PRODUCTION ? (ecfsConfig.SERVER_DOMAIN + ecfsConfig.PROVIEW_FILE_URL + this.data.legal.certificates[0].newName) : (ecfsConfig.SERVER_DOMAIN + ecfsConfig.RAP_URL_PREFIX + ecfsConfig.PROVIEW_FILE_URL + this.data.legal.certificates[0].newName),
              'partyData.isShowLegalCer': false,
            })

          } else {
            this.setData({
              other: party,
              'partyData.otherCerImgUrl': ecfsConfig.IS_PRODUCTION ? (ecfsConfig.SERVER_DOMAIN + ecfsConfig.PROVIEW_FILE_URL + this.data.other.certificates[0].newName) : (ecfsConfig.SERVER_DOMAIN + ecfsConfig.RAP_URL_PREFIX + ecfsConfig.PROVIEW_FILE_URL + this.data.other.certificates[0].newName), 'partyData.isShowOtherCer': false,
            })
          }
        } else {
          console.log(data)
        }
      }).catch(error => {
        console.log(error)
      })
    }
    let that=this
    //取caseId
    wx.getStorage({
      key: 'caseId',
      success: function (res) {
        that.setData({
          caseId: res.data
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})